
#include <bits/stdc++.h>
using namespace std;

const int NK = 2e5 + 5;

void NO(){
    puts("No");
    exit(0);
}

vector<int> G[NK];
int n, k, siz[NK];

void dfs(int u, int fa){
    siz[u] = 1;
    int ch = 0;
    for(int v : G[u]) if(v != fa){
        dfs(v, u);
        if(siz[v]) ch++, siz[u] += siz[v];
    }
    
    if(siz[u] < k){
        if(u == 1 || ch > 1) NO();
    } else if(siz[u] > k){
        NO();
    } else { // siz[u] == k
        if(ch > 2) NO();
        siz[u] = 0;
    }
}

int main(){
    scanf("%d %d", &n, &k);
    for(int i = 1; i < n * k; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    puts("Yes");
    return 0;
}